/*
 *      test.cc
 *      Small testing application.
 *      Will do some bogus file i/o and report its own statistics.
 *      ftrace is supposed to trace us and compare our statistics with what it collected.
 *
 *      The whole process is controlled by bash script.
 */

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
        char buf[512] = {0};
	
	printf("Opening /dev/zero\n");
        FILE* stream = fopen("/dev/zero", "r");
        if(!stream) {
                fprintf(stderr, "Failed opening /dev/zero\n");
                return EXIT_FAILURE;
        }

        ssize_t nread = fread(buf, sizeof(*buf), sizeof(buf), stream);
        if(nread != sizeof(buf)) {
                fprintf(stderr, "Failed reading from /dev/zero: %d\n", ferror(stream));
                return EXIT_FAILURE;
        }

        fclose(stream);
        return EXIT_SUCCESS;
}       
